Skip to content

fix: pass codec options to db.command()#39

Merged
passren merged 1 commit into
passren:mainfrom
msyavuz:fix/command-codec-options
Jul 17, 2026
Merged

fix: pass codec options to db.command()#39
passren merged 1 commit into
passren:mainfrom
msyavuz:fix/command-codec-options

Conversation

@msyavuz

@msyavuz msyavuz commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Database.command() falls back to DEFAULT_CODEC_OPTIONS when codec_options is omitted, so options configured on the client were ignored on every read. Most visibly, uuidRepresentation had no effect: BSON UUID fields were decoded as raw bson.Binary instead of uuid.UUID no matter what the connection string asked for, because reads go through db.command({'find': ...}) rather than collection.find().

  # mongodb://.../db?uuidRepresentation=standard
  cur.execute("SELECT * FROM testUuid")
  cur.fetchall()   # -> Binary(b'\xbc\xf9...', 4)   expected: UUID('bcf9a897-...')

Pass the database's codec options for both find and getMore, so results decode consistently with collection.find() and across batches.

Database.command() falls back to DEFAULT_CODEC_OPTIONS when codec_options is
omitted, so options configured on the client were ignored on every read. Most
visibly, uuidRepresentation had no effect: BSON UUID fields were decoded as raw
bson.Binary instead of uuid.UUID no matter what the connection string asked for,
because reads go through db.command({'find': ...}) rather than collection.find().

Pass the database's codec options for both find and getMore, so results decode
consistently with collection.find() and across batches.
@passren
passren merged commit a3f1102 into passren:main Jul 17, 2026
24 checks passed
@passren

passren commented Jul 17, 2026

Copy link
Copy Markdown
Owner

@msyavuz Thank you for contributing. The PR was merged and it will be included in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants